package leetcode;

public class Day32 {
    class Solution {
        public int canCompleteCircuit(int[] gas, int[] cost) {
            int l=gas.length;
            for(int i=0;i<l;i++){
                int j=i;
                int sum=gas[j];
                while(sum-cost[j]>=0){
                    sum=sum-cost[j]+gas[(j+1)%l];
                    j=(j+1)%l;
                    if(j==i){
                        return i;
                    }
                }
                if(j<i){
                    return -1;
                }
                i=j;
            }
            return -1;
        }
    }
    public static void main(String[] args) {
        System.out.println(0.1+0.2);

        System.out.println(0.1+0.2==0.3);
    }
}

